
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Util extends CI_Controller {
        public function upload(){
        $config['upload_path'] = 'public/uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = 0;
        $config['max_width'] = 10240;
        $config['max_height'] = 7680;

        $this->load->library('upload', $config);

        if ( ! $this->upload->do_upload('file')){
            echo $this->upload->display_errors();     
        }
        else
        {
            echo 'public/uploads/'.$this->upload->data('file_name');
        }
    }
    //    if ($_FILES['file']['error']>0) {
    //         exit("上传错误");
    //     }else{
    //         $path = "public/uploads/".$_FILES['file']['name'];
    //          move_uploaded_file($_FILES['file']['tmp_name'],$path);    //图片上传
    //          echo"public/uploads/".$_FILES['file']['name'];
    //     }
    // }
}
